#pragma once
#include"HashTable.h"
namespace QQ
{
	template<class K>
	class unordered_set
	{
		struct SetKeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};
	public:
		typedef typename hash_bucket::HashTable<K, const K, SetKeyOfT>::Iterator iterator;
		typedef typename hash_bucket::HashTable<K, const K, SetKeyOfT>::ConstIterator const_iterator;
		pair<iterator,bool> insert(const K& key)
		{
			return _s.Insert(key);
		}
	
		iterator begin()
		{
			return _s.Begin();
		}
		iterator end()
		{
			return _s.End();
		}
		const_iterator begin()const
		{
			return _s.Begin();
		}
		const_iterator end() const
		{
			return _s.End();
		}
		iterator find(const K& key)
		{
			return _s.Find(key);
		}
		bool erase(const K& key)
		{
			return _s.Erase(key);
		}
	private:
		hash_bucket::HashTable<K,const K, SetKeyOfT> _s;
	};
	void print(const unordered_set<int>& s)
	{
		unordered_set<int>::const_iterator it = s.begin();
		while (it != s.end())
		{
			//*it = 1;
			cout << *it << " ";
			++it;
		}
		cout << endl;

		for (auto e : s)
		{
			cout << e << " ";
		}
		cout << endl;
	}
	void test_set1()
	{
		int a[] = { 3,11,86,7,88,82,1,881,5,6,7,6 };
		unordered_set<int> s;
		for (auto e : a)
		{
			s.insert(e);
		}
		unordered_set<int>::iterator it = s.begin();
		while (it != s.end())
		{
			//*it = 1;
			cout << *it << " ";
			++it;
		}
		cout << endl;
		for (auto e : s)
		{
			cout << e << " ";
		}
		cout << endl;
		print(s);
	}
}
